import grpc
from concurrent import futures
# from services.stock_service import StockService
# from gen import stock_pb2_grpc
from utils import grpc_utils
from config import settings, logger
import tushare as ts
import pandas as pd
import sys
import os

def serve():
    pass

if __name__ == '__main__':
    pro = ts.pro_api(settings.TUSHARE_TOKEN)
    data = pd.DataFrame()
    if os.path.exists(settings.SHARE_DATA_PATH):
        data = pd.read_csv(settings.SHARE_DATA_PATH)
    else:
        data = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
        data.to_csv(settings.SHARE_DATA_PATH)
    print(data.head())
    if os.path.exists(settings.SHARE_INFO_PATH):
        ts_info = pd.read_csv(settings.SHARE_INFO_PATH)
    else:
        ts_info = pro.stock_company(exchange='', fields='ts_code,com_name,chairman,manager,secretary,reg_capital,setup_date,province,city,introduction,website,employees,main_business,business_scope')
        ts_info.to_csv(settings.SHARE_INFO_PATH)
    print(ts_info.head())
    print(f'{grpc_utils.}')
